#include "smallccompiler.h"
#include <bits/stdc++.h>
using namespace std;

string readFiletoString(string filename){
    ifstream ifs;
    string in;
    ifs.open(filename, ios::in);
    if ( ! ifs.is_open() ){
        cout << "Failed to open the file\n";
    }else{
        char ch;
        while ( ifs.get(ch) ){
            in += ch;
        }
    }
    ifs.close();
    return in;
}

int main(){
    string in = readFiletoString("prime.c");
    // string in = readFiletoString("LCD.c");
    // string in = readFiletoString("test.c");
    string out, instr, table, res;
    cout << in << endl;
    compile(&in, &out, &instr, &table);

    cout << out << endl << endl;
    cout << table << endl << endl;
    cout << instr << endl << endl;

    cout << "res: " << endl;
    interpret(&res);
    cout << res << endl << endl;
    return 0;
}